import request from '@/utils/request';
import { constant } from 'lodash';

// 根据字典类型查询字典信息
export function queryDictByType(type: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/type/' + type,
		method: 'get',
	});
}

// 移动中台能力选项
export function queryMpAbilityOptions(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/mp/ability/option',
		method: 'get',
	});
}

// 移动中台服务选项
export function queryMpServiceOptions(id: string | number): ApiPromise<ApiResponse> {
	return request({
		url: '/management/mp/service/option/' + id,
		method: 'get',
	});
}
// 移动中台服务选项2
export function queryIndicatorServiceOptions(id: string | number): ApiPromise<ApiResponse> {
	const params: any = {};
	return request({
		url: '/management/mp/service/option/' + id,
		method: 'get',
	});
}

// 移动中台单位选项
export function queryMpOrgOptions(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/mp/organization/option',
		method: 'get',
	});
}

// 查询默认的应用系统选项列表
/**
 * @param {number} isStatus 是否启用 1启用
 */
export function queryAppSystemOptions(query?: any): ApiPromise<ApiResponse> {
	const params: any = {};
	if (query && query.isStatus !== undefined) {
		params.isStatus = query.isStatus;
	}
	return request({
		url: '/management/option/system',
		method: 'get',
		params: params,
		headers: {
			VERSION: 'dengfazhu',
		},
	});
}

// 查询所有状态的应用系统选项列表
/**
 * @param {any} data
 */
export function queryAllAppSystemOptions(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryAllAppSystemOptions',
		method: 'get',
		params: {},
	});
}

// 根据系统id获取已确认的业务列表
/**
 * @param {number} id 系统id
 * @param {string} isStatus 是否启用
 */
export function queryBusinessOptions(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/business',
		method: 'get',
		params: {
			systemId: id,
			// isStatus: 1,
		},
	});
}

// 根据系统id获取所有业务列表
/**
 * @param {number} id 系统id
 * @param {} isStatus 是否监控中
 */
export function queryBusinessAllOptions(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/business',
		method: 'get',
		data: {
			systemId: id,
		},
	});
}

// 通过系统id查询所属网端
/**
 * @param {number} id 系统id
 */
export function querySegmentOptions(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/segment',
		method: 'get',
		params: {
			systemId: id,
		},
		headers: {
			VERSION: 'dengfazhu',
		},
	});
}

// 通过网端类型查询所属网端
/**
 * @param {number} id 系统id
 * @param {any} type 网端类型
 */
export function querySegmentOptionsBySegmentType(query: any): ApiPromise<ApiResponse> {
	console.log('querySegmentOptionsBySegmentType', query);
	const params: any = {};
	if (query.systemId !== undefined) {
		params.systemId = query.systemId;
	}
	if (query.type !== undefined) {
		params.type = query.type;
	}
	return request({
		url: '/management/option/segment',
		method: 'get',
		params: params,
		headers: {
			VERSION: 'dengfazhu',
		},
	});
}

// 告警指标查询接口
/**
 * @param {any} data
 */
export function queryIndicatorsOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/alarmIndicators',
		method: 'get',
		params: data,
	});
}

// 基础告警指标查询接口
/**
 * @param {any} data
 */
export function queryBaseIndicatorsOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/baseAlarmIndicators',
		method: 'get',
		params: data,
	});
}

// 自定义告警指标查询接口
/**
 * @param {any} data
 */
export function queryCustomIndicatorsOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/customAlarmIndicators',
		method: 'get',
		params: data,
	});
}

// 基础告警模板查询接口
/**
 * @param {any} data
 */
export function queryBaseTemplateOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/baseAlarmTemplate',
		method: 'get',
		params: data,
	});
}

// 自定义告警模板查询接口
/**
 * @param {any} data
 */
export function queryCustomTemplateOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/customAlarmTemplate',
		method: 'get',
		params: data,
	});
}

// 告警级别查询接口
/**
 * @param {any} data
 */
export function queryAlarmLevelOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/alarmLevel',
		method: 'get',
		params: data,
	});
}

// 告警对象查询接口
/**
 * @param {any} data
 */
export function queryAlarmObjectOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/indicatorsObject',
		method: 'get',
		params: data,
	});
}

// 城市查询接口
/**
 * @param {any} ids
 */
export function queryCityAreaOptions(ids?: any): ApiPromise<ApiResponse> {
	console.log('queryCityAreaOptions',ids)
	if(ids === undefined || ids === null) return;
	return request({
		url: '/management/option/getCityArea/' + ids,
		method: 'get',
		headers: {
			VERSION: 'dengfazhu',
		},
	});
}

// 告警类型查询接口
/**
 * @param {any} data
 */
export function queryAlarmTypeOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/alarmIndicators',
		method: 'get',
		params: data,
	});
}

// 根据业务编码查询步骤查询接口
/**
 * @param {string} code
 * @
 */
export function queryStepOptions(data: any): ApiPromise<ApiResponse> {
	let params;
	console.log('data------------', data);
	if (data instanceof Object) {
		params = {
			isStatus: 1,
			...data,
		};
	} else {
		params = {
			isStatus: 1,
			businessCode: data,
		};
	}

	return request({
		url: '/management/option/step',
		method: 'get',
		params: params,
		headers: {
			VERSION: 'dengfazhu',
		},
	});
}

// 通过系统编码查询所属网端
/**
 * @param {string} code
 */
export function querySegmentBySystemCode(code: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/querySegmentBySystemCode/' + code,
		method: 'get',
	});
}

// 通过系统id查询端类型
/**
 * @param {string} id
 */
export function querySegmentTypeBySystemId(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/querySegmentTypeBySystemId/' + id,
		method: 'get',
	});
}

// 通过系统id查询端类型
/**
 * @param {string} code
 */
export function querySegmentTypeBySystemCode(code: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/querySegmentTypeBySystemCode/' + code,
		method: 'get',
	});
}

// 根据系统编码获取已确认的业务列表
/**
 * @param {string} code
 */
export function queryBusinessBySystemCode(code: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryBusinessBySystemCode/' + code,
		method: 'get',
	});
}

// 根据系统编码获取所有业务列表
/**
 * @param {string} code
 */
export function queryAllBusinessBySystemCode(code: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryAllBusinessBySystemCode/' + code,
		method: 'get',
	});
}

// 根据业务id查询步骤列表
/**
 * @param {string} ids
 */
export function queryStepByBusinessId(ids: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryStepByBusinessId/' + ids,
		method: 'get',
	});
}

// 根据业务编码查询步骤列表
/**
 * @param {string} codes
 */
export function queryStepByBusinessCode(codes: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryStepByBusinessCode/' + codes,
		method: 'get',
	});
}

//----------------告警相关-------------------
// 统计指标列表数据查询
/**
 * @param {any} query
 */
export function queryAdvancedIndicatorsList(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/alarmIndicators/customAlarmIndicators',
		method: 'post',
		data: query,
	});
}

// 查询基础指标列表
/**
 * @param {any} query
 */
export function queryBaseIndicatorsList(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryBaseIndicatorsList',
		method: 'post',
		data: query,
	});
}

// 模板列表数据查询
/**
 * @param {any} query
 */
export function queryAlarmTemplateOptions(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/alarmTemplate',
		method: 'get',
		data: query,
	});
}

// 模块类型
export function queryModuleListForSelect(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryModuleListForSelect',
		method: 'get',
	});
}

// 原始数据规则名称
export function queryRuleNameSelect(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryRuleNameSelect',
		method: 'post',
	});
}

// 原始数据所有协议
export function queryProtocolSelect(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/protocol',
		method: 'get',
	});
}

// 查询系统版本信息
export function querySystemVersion(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/querySystemVersion',
		method: 'get',
	});
}

// 查询数据中心
/**
 * @param {any} data
 */
export function queryDataCenter(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/dataCenter',
		method: 'get',
		params: data,
	});
}

// 查询数据库类型
/**
 * @param {string} centerId
 */
export function queryDatabaseType(centerid: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/databaseType/' + centerid,
		method: 'get',
	});
}

/*根据dict_type参数，查询表sys_dict_data 对应的数据列表*/
/**
 * @param {string} dictType
 */
export function querySysDictDataByDictType(dictType: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/querySysDictDataByDictType/' + dictType,
		method: 'get',
	});
}

/*搜索选项-查询表t_return_code_type对应的数据列表*/
/**
 * @param {any} dictType
 */
export function queryTReturnCodeType(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryTReturnCodeType/',
		method: 'get',
	});
}

// 查询日志模块
/**
 * @param {any} data
 */
export function queryModuleListOption(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/log/config/queryModuleListOption',
		method: 'get',
		params: data,
	});
}

// 事务事项系统下拉列表
/**
 * @param {any} query
 */
export function queryMatterSystemOptions(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/api/affairAndItem/querySystemList',
		method: 'post',
		data: query,
	});
}

// 告警级别查询接口
/**
 * @param {any} data
 */
export function queryAlarmLevel(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/alarmLevel',
		method: 'get',
		params: data,
	});
}

// 高级告警指标查询接口
/**
 * @param {any} data
 */
export function queryCustomIndicators(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryCustomIndicators',
		method: 'get',
		params: data,
	});
}

// 查询应用模块选项列表
/**
 * @param {any} data
 */
export function queryModulesOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/api/appLog/overview/getLogModuleList',
		method: 'get',
		params: data,
	});
}

// 查询IP
/**
 * @param {any} data
 */
export function queryIPsByModule(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/api/appLog/details/getLogIpList',
		method: 'get',
		params: data,
	});
}
// 查询告警类型统计信息
/**
 * @param {any} data
 */
export function queryAlarmTypeStatisInfo(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/api/segment/overview/queryAlarmTypeStatisInfo',
		method: 'post',
		data: data,
	});
}

//共用步骤/接口
/**
 * @param {any} data
 */
export function queryPublicStepOptions(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/step/queryPublicStepOptions',
		method: 'get',
		data: data,
	});
}

//观察类型
/**
 * @param {any} data
 */
export function queryObservationClass(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/queryObservationClass',
		method: 'get',
		data: data,
	});
}

//观察对象
/**
 * @param {any} data
 */
export function queryObservationObject(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/ops-workbench/search/option/queryObservationObject',
		method: 'get',
		data: data,
	});
}

// 查询所有展示字段（步骤查询页面，详单查询，基础告警查询页面）
/**
 * @param {string} type
 */
export function getAllCustomDisplayFields(type: string): ApiPromise<ApiResponse> {
	return request({
		url: '/management/exclusiveIndicator/getAllCustomDisplayFields/' + type,
		method: 'get',
		headers: {
			VERSION: 'lishilei',
		},
	});
}

// 查询单位
export function queryOrg(data: anyObj): ApiPromise<ApiResponse> {
	return request({
		url: '/middle-platform/modules/orgAbilityOverview/queryOrg',
		method: 'post',
		data: data,
	});
}
// 查询服务
export function queryAbilityServer(data: anyObj): ApiPromise<ApiResponse> {
	return request({
		url: '/middle-platform/modules/abilityServer/queryAbilityServer',
		method: 'post',
		data: data,
	});
}

// 查询单位属性
export function page(data: anyObj): ApiPromise<ApiResponse> {
	return request({
		url: `/admin/dict/item/page?dictType=mp_org_type`,
		method: 'get',
		data: data,
	});
}

// 查询单位属性
export function orgTypeAlarmStatistics(data: anyObj): ApiPromise<ApiResponse> {
	return request({
		url: `/middle-platform/modules/platformOverview/orgTypeAlarmStatistics`,
		method: 'post',
		data: data,
	});
}
// 查询系统所属域下拉项
export function querySystemDomainOptions(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/getSystemDomain',
		method: 'post',
	});
}

// 查询所属单位
export function getOrg(): ApiPromise<ApiResponse> {
	return request({
		url: '/management/mp/ability/getOrg',
		// url: '/mp/ability/getOrg',
		method: 'get',
	});
}

// 查询默认时间向前推指定分钟数
export function publicValue(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param/publicValue/mp.time.push',
		method: 'get',
	});
}

// 查询默认时间向前推指定分钟数
export function segment(params: any): ApiPromise<ApiResponse> {
	return request({
		url: '/management/option/segment',
		method: 'get',
		params,
	});
}

//
export function levelType(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/type/sys_alarm_threshold_level',
		method: 'get',
	});
}

// 获取返回码类型
export function returnCodeType(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/type/return_code_type',
		method: 'get',
	});
}
// 获取角色
export function queryRoleList(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/role/list',
		method: 'get',
	});
}
// 获取部门
export function queryDeptTree(query?: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dept/tree',
		method: 'get',
		params: query,
	});
}
// 获取岗位
export function queryPostList() {
	return request({
		url: '/admin/post/list',
		method: 'get',
	});
}
